﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ECRMS.WinForm.WinService;

namespace ECRMS.WinForm.BaseClass.Common
{
    public class Structure
    {
        public List<CtStructure> Structures;
        public CtStructure OperatorRow;

        public FuncResult<CtStructure> GetStructures(Guid ?corpId)
        {
            using (var ser = new ECRServiceClient())
            {
                CtServiceResultOfArrayOfCtStructureOUJwPUXg result = ser.CtGetStructures(corpId);
                if (result.Status == 1)
                {
                    this.Structures = result.Data;
                }
                return new FuncResult<CtStructure> { 
                    Status=result.Status,
                    Message=result.Message
                };
            }
        }

        public FuncResult InsertStructure()
        {
            using (var ser = new ECRServiceClient())
            {
                CtServiceResultOfArrayOfCtStructureOUJwPUXg result = ser.CtInsertStructure(OperatorRow);
                if (result.Status == 1)
                {
                    this.Structures = result.Data;
                }
                return new FuncResult<CtStructure>
                {
                    Status=result.Status,
                    Message=result.Message
                };
            }
        }

        public FuncResult UpdateStructure()
        {
            using (var ser = new ECRServiceClient())
            {
                CtServiceResultOfArrayOfCtStructureOUJwPUXg result = ser.CtUpdateStructure(OperatorRow);
                if (result.Status == 1)
                {
                    this.Structures = result.Data;
                }
                return new FuncResult { 
                    Status=result.Status,
                    Message=result.Message
                };
            }
        }
    }
}
